import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '@/views/home/home.vue'
import Index from '@/views/home/index.vue'
import Cla from '@/views/home/cla.vue'
import Cart from '@/views/home/cart.vue'
import My from '@/views/home/my.vue'
import goods from '@/views/goods/index.vue'
import detail from '@/views/detail/index.vue'
import login from '@/views/login/index.vue'
import register from '@/views/register/index.vue'
import order from '@/views/order/index.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    { path: '/', redirect: '/home/index' },
    {
      path: '/home', component: HomeView, children: [
        { path: 'index', component: Index },
        { path: 'cla', component: Cla },
        { path: 'cart', component: Cart },
        { path: 'my', component: My },
      ]
    },
    { path: '/goods/:query', component: goods },
    { path: '/detail/:goods_id', component: detail },
    { path: '/login', component: login },
    { path: '/register', component: register },
    { path: '/order', component: order },
  ],
})

export default router
